package horncomb.bpm.task.def;

import horncomb.bpm.BpmContextHolder;
import horncomb.bpm.process.core.Token;
import horncomb.bpm.task.core.TaskAssignment;
import horncomb.bpm.task.core.TaskDefinition;
import horncomb.bpm.task.core.TaskInstance;
import horncomb.bpm.task.core.TaskInstanceCreator;
import horncomb.bpm.task.def.asmt.CurrUserTaskAssignment;

/**
 * @author Daniel
 */
public class DefaultTaskDefinition implements TaskDefinition {
	private String id;
	private String name;
	private TaskInstanceCreator taskInstanceCreator;
	private TaskAssignment taskAssignment = new CurrUserTaskAssignment();
	private boolean defaultHiding = false;

	private String type = "default";

	/**
	 * {@inheritDoc}
	 */
	public TaskInstance newInstance(Token token, Object contextModel) {
		return BpmContextHolder.getContext().getTaskManagementServcie()
				.createTaskInstance(token, this, contextModel,
						this.taskInstanceCreator);
	}

	/**
	 * @param taskAssignment
	 *            the taskAssignment to set
	 */
	public void setTaskAssignment(TaskAssignment taskAssignment) {
		this.taskAssignment = taskAssignment;
	}

	/**
	 * {@inheritDoc}
	 */
	public TaskAssignment getTaskAssignment() {
		return taskAssignment;
	}

	/**
	 * {@inheritDoc}
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * {@inheritDoc}
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the taskCreator
	 */
	public TaskInstanceCreator getTaskInstanceCreator() {
		return taskInstanceCreator;
	}

	/**
	 * @param taskInstanceCreator
	 *            the taskCreator to set
	 */
	public void setTaskInstanceCreator(TaskInstanceCreator taskInstanceCreator) {
		this.taskInstanceCreator = taskInstanceCreator;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public boolean isDefaultHiding() {
		return defaultHiding;
	}

	public void setDefaultHiding(boolean hidden) {
		this.defaultHiding = hidden;
	}
}
